package com.kexio.enterprise.governance.circuitbreaker.statistics;

import com.kexio.enterprise.governance.circuitbreaker.enums.CircuitBreakerState;

import java.time.LocalDateTime;
import java.util.Map;

/**
 * 熔断器统计信息
 * 
 * @author Kexio
 * @since 1.0.0
 */
public class CircuitBreakerStatistics {
    private String key;
    private long totalCalls;
    private long successfulCalls;
    private long failedCalls;
    private long timeoutCalls;
    private long rejectedCalls;
    private double successRate;
    private double failureRate;
    private double averageExecutionTime;
    private long maxExecutionTime;
    private long minExecutionTime;
    private long stateTransitions;
    private LocalDateTime startTime;
    private LocalDateTime lastCallTime;
    private Map<CircuitBreakerState, Long> stateDurations; // 各状态持续时间

    // Getters and Setters
    public String getKey() { return key; }
    public void setKey(String key) { this.key = key; }
    
    public long getTotalCalls() { return totalCalls; }
    public void setTotalCalls(long totalCalls) { this.totalCalls = totalCalls; }
    
    public long getSuccessfulCalls() { return successfulCalls; }
    public void setSuccessfulCalls(long successfulCalls) { this.successfulCalls = successfulCalls; }
    
    public long getFailedCalls() { return failedCalls; }
    public void setFailedCalls(long failedCalls) { this.failedCalls = failedCalls; }
    
    public long getTimeoutCalls() { return timeoutCalls; }
    public void setTimeoutCalls(long timeoutCalls) { this.timeoutCalls = timeoutCalls; }
    
    public long getRejectedCalls() { return rejectedCalls; }
    public void setRejectedCalls(long rejectedCalls) { this.rejectedCalls = rejectedCalls; }
    
    public double getSuccessRate() { return successRate; }
    public void setSuccessRate(double successRate) { this.successRate = successRate; }
    
    public double getFailureRate() { return failureRate; }
    public void setFailureRate(double failureRate) { this.failureRate = failureRate; }
    
    public double getAverageExecutionTime() { return averageExecutionTime; }
    public void setAverageExecutionTime(double averageExecutionTime) { this.averageExecutionTime = averageExecutionTime; }
    
    public long getMaxExecutionTime() { return maxExecutionTime; }
    public void setMaxExecutionTime(long maxExecutionTime) { this.maxExecutionTime = maxExecutionTime; }
    
    public long getMinExecutionTime() { return minExecutionTime; }
    public void setMinExecutionTime(long minExecutionTime) { this.minExecutionTime = minExecutionTime; }
    
    public long getStateTransitions() { return stateTransitions; }
    public void setStateTransitions(long stateTransitions) { this.stateTransitions = stateTransitions; }
    
    public LocalDateTime getStartTime() { return startTime; }
    public void setStartTime(LocalDateTime startTime) { this.startTime = startTime; }
    
    public LocalDateTime getLastCallTime() { return lastCallTime; }
    public void setLastCallTime(LocalDateTime lastCallTime) { this.lastCallTime = lastCallTime; }
    
    public Map<CircuitBreakerState, Long> getStateDurations() { return stateDurations; }
    public void setStateDurations(Map<CircuitBreakerState, Long> stateDurations) { this.stateDurations = stateDurations; }
}
